Dementia is a common and greatly feared condition associated with aging. In the United States, the prevalence of dementia is expected to nearly triple to 13 million persons by 2050. Type 2 diabetes mellitus (T2DM), a risk factor for dementia, is also rapidly increasing. Emerging data suggests the first line treatment for T2DM, metformin, may decrease dementia risk. In animal models, metformin improves memory and appears to protect against dementia. If this finding is established in humans, it could inform clinical decisions including how early in the course of diabetes to initiate metformin and whether to continue metformin when patients transition to insulin. However, definitive data are lacking. Randomized controlled trials (RCTs) have not been conducted to study whether metformin prevents dementia in humans. It would be premature to conduct an RCT given the current state of the literature and the high cost and long follow-up time required. Inconsistent results from extant observational studies may be due to inadequate control for confounding. The current proposal uses rich electronic health data resources from the Veterans Health Administration (VA) and Group Health (GH), an integrated healthcare system in the Northwest United States, to conduct a rigorous retrospective cohort study of the association between metformin use and incident dementia. We will use electronic health records (EHR) to identify a cohort of about 100,000 VA patients and 20,000 GH patients who have T2DM and are free of dementia and not taking diabetes medications at baseline. We will use a new user design and state of the art analytic methods including propensity scores and inverse probability of treatment weighting to control for potential confounding factors including diabetes severity. The long observation periods (17 years in VA and 20 years in GH) will ensure adequate power. The rich EHR data including diagnoses, procedures, laboratory and vital signs measures will enable us to control for many potential confounding factors such as hemoglobin A1c levels, medical and psychiatric comorbidities, and the use of concomitant medications. The primary analysis will use VA data, and findings will be replicated using GH data; independent replication in two unique large healthcare systems will improve the validity of our findings. We will address the following specific aims: 1. Compare risk of dementia in people initiating metformin for T2DM versus those initiating a sulfonylurea. 2. Compare risk of dementia in people initiating metformin vs. those delaying initial pharmacologic therapy, 3. Determine if the metformin ? dementia association varies by age groups (50-65 vs. >65 years of age) and by gender. Exploratory analysis will investigate metformin dose and duration and risk of dementia. By using the same measures and methods to replicate results in very different patient populations, we will generate the strongest evidence to date regarding metformin?s potential to reduce risk of dementia. Results will inform provider-patient discussions about metformin use and could guide design of a subsequent, efficient RCT that targets people most likely to benefit from metformin.